package com.yugao.fintech.draper.security.customizer;

import com.yugao.fintech.draper.security.authentication.social.GiteeAuthenticationConverter;
import com.yugao.fintech.draper.security.authentication.password.PasswordAuthenticationConverter;
import com.yugao.fintech.draper.security.authentication.sms.SmsAuthenticationConverter;
import org.springframework.security.oauth2.server.authorization.web.authentication.*;
import org.springframework.security.web.authentication.AuthenticationConverter;

import java.util.Arrays;
import java.util.List;

public interface AccessTokenRequestConverterCustomizer {

	List<AuthenticationConverter> CONVERTERS = Arrays.asList(
			// 自定义的gitee oauth2登录
			new GiteeAuthenticationConverter(),

			// 自定义的验证码模式Converter
			new SmsAuthenticationConverter(),

			// 自定义的密码模式Converter
			new PasswordAuthenticationConverter(),

			// 内置的刷新tokenConverter
			new OAuth2RefreshTokenAuthenticationConverter(),

			// 内置的客户端凭据Converter
			new OAuth2ClientCredentialsAuthenticationConverter(),

			// 内置的授权码Converter
			new OAuth2AuthorizationCodeAuthenticationConverter(),

			// 内置的授权码请求Converter
			new OAuth2AuthorizationCodeRequestAuthenticationConverter());

	static AuthenticationConverter customizer() {
		return new DelegatingAuthenticationConverter(CONVERTERS);
	}

}
